package Data;

import java.util.*;

public class Class {
	static int numberOfClass = 0;
	long id;
	String name;
	LinkedList<String> bases;
	LinkedList<String> attributes;
	LinkedList<String> methods;
	
	public Class() {
		id = numberOfClass;
		numberOfClass++;
		name = "a";
		bases = new LinkedList();
		attributes = new LinkedList();
		methods = new LinkedList();
	}
	
	public Class(Class c) {
		this();
		if (c != null) {
			name = c.name;
			bases = new LinkedList(c.bases);
			attributes = new LinkedList(c.attributes);
			methods = new LinkedList(c.methods);
		}
	}
	
	public long getID() {
		return id;
	}
	
	public boolean addBase(String b) {
		if (bases.indexOf(b) == -1) {
			bases.addLast(b);
			return true;
		} else return false;
	}
	
	public void addAttribute(String a) {
		if (canUpdateAttribute(a)) {
			attributes.addLast(a);
		}
	}
	
	public void addMethod(String m) {
		if (canUpdateMethod(m)) {
			methods.addLast(m);
		}
	}
	
	public void updateAttribute(String a, String b) {
		if (canUpdateAttribute(b)) {
			attributes.set(attributes.indexOf(a), b);
		}
	}
	
	public void updateMethod(String a, String b) {
		if (canUpdateMethod(b)) {
			methods.set(methods.indexOf(a), b);
		}
	}
	
	public void removeBase(String b) {
		bases.remove(b);
	}
	
	public void removeAttribute(String a) {
		attributes.remove(a);
	}
	
	public void removeMethod(String m) {
		methods.remove(m);
	}
	
	public LinkedList<String> getBases() {
		return new LinkedList(bases);
	}
	
	public LinkedList<String> getAttributes() {
		return new LinkedList(attributes);
	}
	
	public LinkedList<String> getMethods() {
		return new LinkedList(methods);
	}
	
	public boolean canUpdateAttribute(String a) {
		if (attributes.indexOf(a) == -1) return true;
		else return false;
	}
	
	public boolean canUpdateMethod(String m) {
		if (methods.indexOf(m) == -1) return true;
		else return false;
	}
}
